//
//  MM_PreLoadVC.m
//  MallManage_IOS
//
//  Created by 张浩 on 2023/9/11.
//

#import "MM_PreLoadVC.h"
#import "MM_LoginVC.h"
#import "MM_HomeManageVC.h"
#import "MM_AlertView.h"

@interface MM_PreLoadVC ()

/**  加载图  */
@property (nonatomic,strong) UIImageView * imageView;

@end

@implementation MM_PreLoadVC

- (void)viewDidLoad {
    [super viewDidLoad];
     
    _imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    _imageView.backgroundColor = [UIColor redColor];
    [self.view addSubview:_imageView];
    
//    NSString * imageName = [NSString stringWithFormat:@"Launch%.0f-%.0f",ScreenW*[UIScreen mainScreen].scale,ScreenH*[UIScreen mainScreen].scale];
//    UIImage * image = [UIImage imageNamed:imageName];
//    if (image == nil) {
//        image = [UIImage imageNamed:@"Launch1242-2688"];
//    }
//    _imageView.image = image;
    
    [self enterHome];
}

- (void)enterHome {
    
    if ([MM_Cache shareMM_Cache].userModel.user_id.integerValue > 0) {
        
        MM_HomeManageVC *manageVC = [[MM_HomeManageVC alloc] init];
        UINavigationController *nav = [[UINavigationController alloc]   initWithRootViewController:manageVC];
        AppDelegate.appDelegate.window.rootViewController = nav;
        
    } else {
        
        MM_LoginVC *loginVC = [[MM_LoginVC alloc] init];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVC];
        AppDelegate.appDelegate.window.rootViewController = nav;
    }
    
}

- (void)jumpTestFlight {
    
    NSString *urlString = @"beta.itunes.apple.com/v1/app/6465894068";
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"itms-beta://"]]) {
        urlString = [NSString stringWithFormat:@"itms-beta://%@",urlString];
        NSURL *url = [NSURL URLWithString:urlString];
        [[UIApplication sharedApplication] openURL:url];
    }else{
        urlString = [NSString stringWithFormat:@"https://%@",urlString];
        NSURL*url = [NSURL URLWithString:urlString];
        [[UIApplication sharedApplication] openURL:url];
    }
}

@end
